﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace TV_Organizer.Subtitles
{
    class SelectedSubtitlesNumberConverter : IMultiValueConverter
    {
        private static SelectedSubtitlesNumberConverter _instance;
        public static SelectedSubtitlesNumberConverter Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new SelectedSubtitlesNumberConverter();
                return _instance;
            }
        }

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var subs = values.OfType<IEnumerable<Subtitle>>().FirstOrDefault();
            if (subs == null) return 0;

            return subs.Where(s => s.IsSelected).Count().ToString();
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
